1ea7e0
@@ -580,11 +580,14 @@
public int read(byte[] buf, int offset, int numToRead) throws IOException {
         numToRead = Math.min(numToRead, available());
         
         totalRead = is.read(buf, offset, numToRead);
-        count(totalRead);
         
         if (totalRead == -1) {
+            if (numToRead > 0) {
+                throw new IOException("Truncated TAR archive");
+            }
             hasHitEOF = true;
         } else {
+            count(totalRead);
             entryOffset += totalRead;
         }
 
